perm filename IOPKG.SAI[LIB,AIL]1 blob
sn#408152 filedate 1979-01-09 generic text, type C, neo UTF8
COMMENT ā VALID 00003 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 entry OpenIn,OpenOut,!n!e!w!i!n!l!i!n!e
C00007 00003 internal simple integer procedure OpenOut(string FileName
C00011 ENDMK
Cā;
entry OpenIn,OpenOut,!n!e!w!i!n!l!i!n!e;
begin "IOPkg"
define library!entry = true;
require "sys:std.hdr" source!file;
!*** History: 12-Nov-78 add escape and Warn stuff -Raj.
/ / / / / creation -J. Low.
;
define BIT(n)=[(1 lsh (35-n))];
define escape='33;
external integer !skip!;
boolean Warn;
internal integer !c!o!u!n!t,!b!r!c!h!a!r;
internal boolean array !n!e!w!i!n!l!i!n!e[0:15];
simple procedure InitCnt;
!c!o!u!n!t := 200;
require InitCnt initialization;
internal simple integer procedure OpenIn(string FileName;
reference integer Eof; integer Mode(0));
begin "OpenIn"
string Name,Ext,Dev,PPN;
integer Chan,Flag;
label Start;
Warn := (Mode land (BIT(23))=0); ! silent mode if bit 23 is on;
Chan := GetChan;
if Chan = -1 then
begin
if Warn then
UserErr(0,1,"***OpenIn: All Channels are in use. (Limit"&
" of 16 open files). OpenIn aborted.");
return(-1);
end;
Start:
Eof := true; ! want to handle Device errors here;
while not FileScan(FileName,Dev,Name,Ext,PPN) do
begin
if not Warn then return(-1);
OutStr(CrLf&Tab&"*** OpenIn: BAD FILENAME SYNTAX = """&
FileName&"""."&CrLf&Tab&"ENTER FILENAME FROM "&
"TERMINAL."&CrLf);
OutStr("FILENAME? -");
FileName := InChWL;
if !skip!=escape then
begin
print("*** OpenIn aborted.", crlf);
return(-1); ! quit and exit;
end;
end;
open(Chan,Dev,Mode,2,0,!c!o!u!n!t,!b!r!c!h!a!r,Eof);
if Eof then
begin
if not Warn then return(-1);
OutStr(CrLf&"***OpenIn- - Can't open Device """&
Dev&""". Enter fileName from terminal."&CrLf);
OutStr("FILEName? -");
FileName := InChWL;
if !skip!=escape then
begin
print("*** OpenIn aborted.", crlf);
return(-1); ! quit and exit;
end;
go to Start;
end;
! now try the lookup;
lookup(Chan,Name&"."&Ext&PPN,Flag);
if Flag then
begin
if not Warn then
begin
release(Chan);
return(-1);
end;
OutStr(CrLf&"***OpenIn- Can't open file """&
FileName&""". Enter fileName from terminal."&CrLf);
OutStr("FILEName? -");
FileName := InChWL;
if !skip!=escape then
begin
print("*** OpenIn aborted.", crlf);
release(Chan);
return(-1);
end;
go to Start;
end;
!n!e!w!i!n!l!i!n!e[Chan] := true; ! we're positioned at
beginning of input line;
return(Chan);
end "OpenIn";
internal simple integer procedure OpenOut(string FileName;
integer Mode(0));
begin "OpenOut"
string Name,Ext,Dev,PPN;
integer Chan,Flag,dummy,Eof;
label Start;
Warn := (Mode land (BIT(23))=0); ! silent mode if bit 23 is on;
Chan := GetChan;
if Chan = -1 then
begin
if Warn then
UserErr(0,1,"***OpenIn: All Channels are in use. (Limit"&
" of 16 open files). OpenOut aborted.");
return(-1);
end;
Start:
while not FileScan(FileName,Dev,Name,Ext,PPN) do
begin
if not Warn then return(-1);
OutStr(CrLf&Tab&"*** OpenOut: BAD FILEName SYNTAX = """&
FileName&"""."&CrLf&Tab&"ENTER FILEName FROM "&
"TERMINAL."&CrLf);
OutStr("FILEName? -");
FileName := InChWL;
if !skip!=escape then
begin
print("*** OpenOut aborted.", crlf);
return(-1); ! quit and exit;
end;
end;
Eof := true; ! want to handle Device errors here;
open(Chan,Dev,Mode,0,2,dummy,dummy,Eof);
if Eof then
begin
if not Warn then return(-1);
OutStr(CrLf&"***OpenOut- - Can't open Device """&
Dev&""". ENTER fileName from terminal."&CrLf);
OutStr("FILEName? -");
FileName := InChWL;
if !skip!=escape then
begin
print("*** OpenOut aborted.", crlf);
return(-1); ! quit and exit;
end;
go to Start;
end;
! now try the ENTER;
Enter(Chan,Name&"."&Ext&PPN,Flag);
if Flag then
begin
if not Warn then
begin
release(Chan);
return(-1);
end;
OutStr(CrLf&"***OpenOut- Can't open file """&
FileName&""". Enter fileName from terminal."&CrLf);
OutStr("FILEName? -");
FileName := InChWL;
if !skip!=escape then
begin
print("*** OpenOut aborted.", crlf);
release(Chan);
return(-1);
end;
go to Start;
end;
return(Chan);
end "OpenOut";
end "IOPkg"